package com.zhongnan.demo6.queue;

import com.zhongnan.demo6.shengchanxiaofei.Desk;

import java.util.concurrent.ArrayBlockingQueue;

public class Cooker extends Thread {
    private ArrayBlockingQueue<String> abq;

    public Cooker(ArrayBlockingQueue<String> abq) {
        this.abq = abq;
    }

    /*厨师步骤
    判断桌子上是否有汉堡，有就等待
    没有就生产
    把汉堡放在桌上
    叫醒等待的消费者
     */
    @Override
    public void run() {
        while (true) {
            try {
                abq.put("汉堡");
                System.out.println("厨师做了一个汉堡");
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }
    }
}

